package amap.com.StepCount;

import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.Sensor;

public class StepForCounter implements SensorEventListener {

    public interface StepCountListener2{
        void onStep(SensorEvent event);
    }

    private StepCountListener2 mStepCountListener2;

    public void setStepListener(StepCountListener2 sl){
        mStepCountListener2=sl;
    }

    private SensorManager sensorManager;

    public StepForCounter(SensorManager sensorManager){
        this.sensorManager=sensorManager;
        sensorManager.registerListener(this,sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER),SensorManager.SENSOR_DELAY_UI);

    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        if(mStepCountListener2!=null){
            mStepCountListener2.onStep(event);
        }
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }
}
